//
//  ScreenCollectionViewCell.swift
//  koolcar
//
//  Created by kuaimaxiansheng on 2023/10/11.
//

import UIKit

class ScreenCollectionViewCell: UICollectionViewCell {
    
    var bgView: UIView!
    var titleLab: UILabel!
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.clipsToBounds = true
        self.backgroundColor = .white
        self.initUI()
    }
    
    func initUI(){
        
        self.bgView = UIView(frame: CGRectZero)
        self.bgView.backgroundColor = .white
        self.bgView.layer.cornerRadius = 16
        self.bgView.clipsToBounds = true
        self.bgView.layer.borderWidth = 1
        self.bgView.layer.borderColor = UIColor(hex: 0x939AA8 ,alpha: 0.12).cgColor
        self.contentView.addSubview(self.bgView)
        
        self.titleLab = UILabel(frame: CGRectZero)
        self.titleLab.font = UIFont.init(name: Theme.PingFangSCRegular, size: 12)
        self.titleLab.textColor = Theme.titleLabColor
        self.titleLab.textAlignment = .center
        self.bgView.addSubview(self.titleLab)
        self.titleLab.text = MMLocalizedString("all", comment: "全部")
        
        self.addLayout()
    }
    
    func addLayout(){
        
        self.bgView.snp.makeConstraints { make in
            make.top.equalTo(0)
            make.left.equalTo(0)
            make.right.equalTo(0)
            make.height.equalTo(32)
            make.bottom.equalTo(0)
        }
        
        self.titleLab.snp.makeConstraints { make in
            make.top.equalTo(0)
            make.left.equalTo(10)
            make.right.equalTo(-10)
            make.height.equalTo(32)
        }
        
    }
   
    
    
    
    
    //品牌
    func setBrandModel(model: BrandSeriesListModel){
        if model.isSelect == true{
            self.bgView.backgroundColor = Theme.mainColor
            self.titleLab.textColor = .white
        }else{
            self.bgView.backgroundColor = .white
            self.titleLab.textColor = Theme.titleLabColor
        }
        self.titleLab.text = model.brandName ?? ""
    }
    
    
    //车系
    func setSeriesModel(model: SeriesListModel){
        if model.isSelect == true{
            self.bgView.backgroundColor = Theme.mainColor
            self.titleLab.textColor = .white
        }else{
            self.bgView.backgroundColor = .white
            self.titleLab.textColor = Theme.titleLabColor
        }
        self.titleLab.text = model.name ?? ""
    }
    
    
    
    
    //车型
    func setCarModel(model: CarModelDataList){
        if model.isSelect == true{
            self.bgView.backgroundColor = Theme.mainColor
            self.titleLab.textColor = .white
        }else{
            self.bgView.backgroundColor = .white
            self.titleLab.textColor = Theme.titleLabColor
        }
        self.titleLab.text = model.carCategory ?? ""
    }
    
    //座位
    func setSeatModel(model: ScreenModel){
        if model.isSelect == true{
            self.bgView.backgroundColor = Theme.mainColor
            self.titleLab.textColor = .white
        }else{
            self.bgView.backgroundColor = .white
            self.titleLab.textColor = Theme.titleLabColor
        }
        self.titleLab.text = model.name
    }
    
    
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
